# STAT 202 Project
# SVM
# Author: Fatih Sunor
#####################################################

# Read data
rm(list = ls(all = TRUE));
train <- read.csv("training.csv",header=TRUE);
feature1 <- c(train[1:500,6:7], log(sqrt(train[1:500,9]*train[1:500,10])+1), train[1:500,11]);
relevance1 <- as.factor(train[[13]]);
relevance1<-relevance1[1:500];

# SVM
temp<-data.frame(relevance,feature);
model<-svm(relevance~.,data=temp); 
p<-predict(model, feature);

# Test
sum(relevance!=p)/length(relevance);


# SVM
temp<-data.frame(relevance,feature);
model<-svm(relevance~.,data=temp,kernel='linear'); 
p<-predict(model, feature);
